<template>
	<view class="container">
		<!-- 官方榜 -->
		<view class="officialList">
			<view class="title">
				<image src="../../static/images/logo.png"></image>
				<text>官方榜</text>
			</view>
			<view class="songSheetInfo" v-for="item in allTopList[0]" :key="item.id"
			@tap="toSongSheetDetail(item.id)">
				<view class="updateTime">{{item.updateFrequency}}</view>
				<view class="left">
					<view class="songSheetName">{{item.name}}</view>
					<image :src="item.coverImgUrl"></image>
				</view>
				<view class="right">
					<text class="songName" v-for="(i,idx) in item.tracks" :key="idx">
					{{idx+1}} . {{i.first}} - {{i.second}}
					</text>
				</view>
			</view>
		</view>
		<!-- 其他榜 -->
		<view class="other">
			<view class="tit">综合榜</view>
			<view class="songSheetList">
				<view class="listItem" v-for="item in allTopList[1]" :key="item.id"
				@tap="toSongSheetDetail(item.id)">
					<image class="cover" :src="item.coverImgUrl?item.coverImgUrl:item.picUrl"></image>
					<view class="playConut">
						<text class="iconfont icon-bofang1"></text>
						<text>{{item.playCount>100000000?parseInt(item.playCount/100000000)+'亿':parseInt(item.playCount/10000)+'万'}}</text>
					</view>
					<text class="title">{{item.name}}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				allTopList:[[], []],
			}
		},
		onLoad() {
			this.getAllTopList()
		},
		methods: {
			async getAllTopList(){
				const toplist = await this.$myRequest('/toplist/detail')
				
				toplist.list.forEach(item => {
				      if (item.tracks.length != 0) {
				        this.allTopList[0].push(item)
				      } else {
				        this.allTopList[1].push(item)
				      }
				    })
			},
			// 点击跳转到歌单详情页
			toSongSheetDetail(songSheetId){
				uni.navigateTo({
					url:'/pages/songSheetDetail/songSheetDetail?songSheetId=' + songSheetId
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		height: 100%;
		background-color: #eeeeee;
	}
.container {
	// 官方榜
	margin: 20rpx;
	
	.officialList {
		.title {
			display: flex;
			padding: 20rpx 0;
			image {
				width: 50rpx;
				height: 50rpx;
				border-radius: 50%;
				margin-right: 10rpx;
			}
			text {
				font-weight: bolder;
				font-size: 36rpx;
			}
		}
		.songSheetInfo {
			position: relative;
			background-color: #fff;
			box-sizing: border-box;
			height: 300rpx;
			padding: 30rpx;
			margin-bottom: 20rpx;
			border-radius: 20rpx;
			display: flex;
			.updateTime {
				position: absolute;
				top: 0;
				right: 0;
				padding: 10rpx;
				color: #aaa;
				font-size: 24rpx;
			}
			.left {
				margin-right: 20rpx;
				text-align: center;
				.songSheetName {
					font-size: 50rpx;
					padding-bottom: 10rpx;
					color: $cloundMusic-color;
				}
				image {
					width: 160rpx;
					height: 160rpx;
					border-radius: 8rpx;
				}
			}
			.right {
				width: calc(100vw - 280rpx);
				box-sizing: border-box;
				padding: 20rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-around;  
				.songName {
					font-size: 28rpx;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
					
				}
			}
		}
	}
	.other {
		.tit {
			font-weight: bolder;
			font-size: 36rpx;
			padding: 20rpx 0;
		}
		.songSheetList {
			width: 100%;
			display: flex;
			flex-wrap: wrap;
			box-sizing: border-box;
			// text-align: center;
			.listItem {
						/* #ifdef H5 */
						display: inline-block;// H5支持
						/* #endif */
						position: relative;
						width: 31%;
						height: 320rpx;
						line-height: 36rpx;
					.cover {
						  width: 100%;
						  height: calc(33vw - 20rpx);
						  border-radius: 20rpx;
					}
					.playConut {
						position: absolute;
						right: 0;
						top: 0;
						color: #fff;
						font-size: 26rpx;
						margin: 10rpx;
						padding: 0 15rpx;
						background: rgba(161,162,162,0.5);
						border-radius: 10rpx;
						// filter: blur(20px);
						.iconfont {
							font-size: 22rpx;
						}
					}
					.title {
						  font-size: 26rpx;
						  margin-top: 10rpx;
						  color: rgb(56, 56, 56);
						  text-align: left;
					}
			}
			.listItem:nth-child(3n+2){
			  margin:0 3.5%;
			}
		}
	}
}
</style>
